package com.situ.mall.controller;

import com.situ.common.util.Result;
import com.situ.mall.pojo.vo.CategoryProductVO;
import com.situ.mall.pojo.vo.OrderCountVO;
import com.situ.mall.pojo.vo.ProductSalesVO;
import com.situ.mall.pojo.vo.SalesVolumeVO;
import com.situ.mall.service.ICategoryService;
import com.situ.mall.service.IOrderService;
import com.situ.mall.service.IProductService;
import com.situ.mall.service.IUserService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/echarts")
public class EChartsController {
    @Autowired
    private IProductService productService;
    @Autowired
    private IOrderService orderService;
    @Autowired
    private ICategoryService categoryService;
    @Autowired
    private IUserService userService;

    @RequestMapping("/productSales")
    public Result productSales() {
        List<ProductSalesVO> list = productService.productSales();
        return Result.ok(list);
    }

    @RequestMapping("/TotalSalesByDay")
    public Result TotalSalesByDay() {
        List<SalesVolumeVO> list = orderService.TotalSalesByDay();
        return Result.ok(list);
    }

    @RequestMapping("/selectBrandCount")
    public Result selectBrandCount() {
        List<CategoryProductVO> list = categoryService.selectBrandCount();
        return Result.ok(list);
    }
    @RequestMapping("/selectCount")
    public Result selectCount() {
        Integer orderTotal = orderService.totalCost();
        Integer userTotal = userService.totalCost();
        Integer productTotal = productService.totalCost();
        Integer evaluateTotal = userService.totalCostEvaluate();
        Map<String, Object> map = new HashMap<>();
        map.put("orderTotal", orderTotal);
        map.put("userTotal", userTotal);
        map.put("productTotal", productTotal);
        map.put("evaluateTotal", evaluateTotal);
        return Result.ok(map);
    }
    @RequestMapping("/selectTotalOrder")
    private Result selectTotalOrder() {
        List<OrderCountVO> list = orderService.selectTotalOrder();
        return Result.ok(list);
    }
}
